<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%@include file="../include/base.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
	<title>CRM-deal</title>
	<%@ include file="../include/head.jsp" %>
	<meta charset="UTF-8">
	<title></title>	
</head>
<body class="crm">
	
	<jsp:include page="../include/top.jsp">
		<jsp:param value="deal" name="tag"/>
	</jsp:include>
	
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span8">
				<div class="well screen">
				
				
					<div class="page-header header">
					
					当前所有的交易
					<span> ${fn:length(dealList) } 个交易，价值 ￥${totalMoney }</span>

					</div>
					<c:if test="${fn:length(dealList) == 0}">
						<div class="alert alert-info">
							还没有任何交易！您可以
							<a class="btn btn-primary" href="add.action">
								<i class="icon-plus"></i>
								添加交易
							</a>
						</div>
					</c:if>

					
					<div class="main" id="main">
						<table class="table crm-table" id="deal">
							<tbody>
								
								<%-- <c:forEach items="${dealList }" var="deal" varStatus="d">
									
									<tr>
									<td>
										<h4>
											<a href="show.action?id=${deal.dealid }">
												<c:out value="【${d.count}】 ${deal.dealname}"/>
											</a>
										</h4>
										<blockquote>
										<div>${deal.content }</div>
										<div>
												<span style="background:#${deal.dealtype.color};" class="label">${deal.dealtype.dealtype }</span>
											<c:if test="${deal.money != null }">
												￥${deal.money }
											</c:if>
											<c:if test="${deal.money == null }">
												没有设置金额
											</c:if>
										</div>
										<small>由  ${deal.user.username } 负责</small>
										</blockquote>
									</td>
									<td class="actions" style="width:60px">
										<span class=" label" >${deal.state }</span>
									</td>
								</tr> 
								</c:forEach> --%>	
									
									
									
								  <c:forEach items="${dealList }" var="dl">
							    			
							    		<tr>
								    		<c:if test="${dl.moneytype == '$' }">
								    			<td rowspan="2" width="15%">
								    				<img src="../styles/img/dollar.png"/>
								    			</td>
								    		</c:if>
											<c:if test="${dl.moneytype == '￥'  }" >
												<td rowspan="2" width="15%">
								    				<img src="../styles/img/yuan.png"/>
								    			</td>
											</c:if>
											
											<td width="30%"><a href="<%=basePath%>deal/toDealnote.action?did=${dl.dealid }">${dl.dealname }</a></td>
											<td><span  style="background: ${dl.dealtype.color }">${dl.dealtype.dealtype }</span></td>
											<td width="15%" class="actions" style="width:60px">
												<span class=" label" >${dl.state }</span>
											</td>
										</tr>
										<tr>
											
											<td width="30%">${dl.content }</td>
											<td>${dl.moneytype }${dl.money * dl.times }，共${dl.times }${dl.timetype }，每${dl.timetype }${dl.money }${dl.moneytype }</td>
											<td width="15%">由${dl.user.username }负责</td>
										</tr>
										
												
								   </c:forEach>
							</tbody>
						</table>
	
					</div>
				</div>
			</div>
			
			<script type="text/javascript">
				$(document).ready(function() {
					//state = $(".span_state").text();
					$(".label").each(function(i) {
						state = $(this).text()
						if(state == "跟踪") {
							$(this).addClass("label-pending");
						} else if(state == "成功") {
							$(this).addClass("label-success");
						} else if(state == "失败"){
							$(this).addClass("label-important");
						}
						});
				});
			</script>
			
			
			<div class="span4 sidebar">
				<div class="well">
					<a href="<%=basePath %>deal/toAddDeal.action" class="btn btn-primary">添加新交易</a>
				</div>
	
				<div class="well">
					<div class="title">
						显示方式
					</div>
					<div class="control-group select optional">
						
						<div class="controls">
							<select id="state_select" name="states" onchange="window.location.href='select.action?states=' + $(this).val()">
								<option value="">--请选择显示方式--</option>
								<option value="all">所有交易</option>
								<option value="pending">进行中</option>
								<option value="won">成功</option>
								<option value="lost">失败</option>
							</select>
						</div>
					</div>
					<input type="hidden" id="state_value" value="${states }">
					
					<script type="text/javascript">
						$(document).ready(function(){
							var states = $("#state_value").val();
							$("#state_select option").each(function(i){
								if(states == $(this).val()) {
									$(this).attr("selected","selected");
								}
							});
						});
					</script>
				</div>

			</div>
		</div>
	</div>
</body>
</html>
